import {getUsers} from "@/api/user";

export default {
    namespaced: true,
    state: () => ({
        userList: []
    }),
    actions: {
        async initUserList({commit}) {
            const resp = await getUsers()
            const {code, data} = resp
            if (code !== 1) return
            if (!!data && data.length) {
                commit('setUsers', data)
            }
        }
    },
    mutations: {
        setUsers(state, value) {
            state.userList = value
        }
    }
}
